home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / tpfast30.zip / FASTFILE.ASM < prev    next >
Assembly Source File  |  1990-09-26  |  23KB  |  461 lines

  1. ;   _______________________________________________________________
  2. ;  |                                                               |
  3. ;  |            Copyright (C) 1989,1990  Steven Lutrov             |
  4. ;  |_______________________________________________________________|____
  5. ;  |                                                               |    |
  6. ;  |  Program Title : Fastfile.Asm                                 |    | ___
  7. ;  |  Author        : Steven Lutrov                                |    |    |
  8. ;  |  Revision      : 2.01                                         |    |    |
  9. ;  |  Date          : 1990-03-16                                   |    |    |
  10. ;  |  Language      : Turbo Assembler                              |    |    |
  11. ;  |                                                               |    |    |
  12. ;  |                                                               |    |    |
  13. ;  |  Description   : Assembly functions For primitive file        |    |    |
  14. ;  |                : handeling.                                   |    |    |
  15. ;  |                : Tested on Turbo Pascal Turbo Pascal 5.5      |    |    |
  16. ;  |                                                               |    |    |
  17. ;  |_______________________________________________________________|    |    |
  18. ;      |                                                                |    |
  19. ;      |________________________________________________________________|    |
  20. ;          |                                                                 |
  21. ;          |_________________________________________________________________|
  22. ;
  23.  
  24.  
  25.  
  26. Code Segment Word Public
  27.  
  28. Assume Cs:Code,Ds:Data
  29.  
  30.  
  31. Public Closefile,Createfile,Erasefile,Fmovepointer,Openfile,Readfile,
  32. Public Writefile,Getverify,Getvolume,Readsector,Setverify,Setvolume
  33. Public Writesector
  34.  
  35.  
  36.  
  37. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  38. ;Function Getverify: Boolean;
  39. ;
  40. ;
  41. Getverify Proc Far
  42.         Mov  Ah,54H                     ;Dos Func To Get Verify
  43.         Int  21H                        ;Get Status
  44.         Ret
  45. Getverify Endp
  46.  
  47.  
  48. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  49. ;Function Getvolume(Disk: Integer; Workarea: Pointer): Stype;
  50. ;
  51. ;
  52. Getvolume Proc Far
  53.                 Push Bp                         ;Save Turbos Bp
  54.                 Mov  Bp,Sp                      ;
  55.                 Push Ds                         ;Save Turbo'S Ds
  56.                 Mov  Ah,2Fh                     ;Save Current Dta
  57.                 Int  21H                        ;
  58.                 Push Es                         ;
  59.                 Push Bx                         ;
  60.                 Cld                             ;Set Direction Flag
  61.                 Lds  Dx,Dword Ptr[Bp+6]         ;Ds:Dx Pts To Workarea
  62.                 Mov  Ah,1Ah                     ;Function To Set Dta
  63.                 Int  21H                        ;Set Dta
  64.                 Mov  Si,Dx                      ;Point Si To Dta
  65.                 Mov  Al,[Bp+10]                 ;Get Drive Specifier
  66.                 Or   Al,Al                      ;0 = Current Drive
  67.                 Jnz  Getv1                      ;Jump If Not Current
  68.                 Mov  Ah,19H                     ;Dos Func To Get Drv Num
  69.                 Int  21H                        ;Get Current Drive
  70.                 Inc  Al                         ;Count Drives From 1
  71. Getv1:          Add  Al,64                      ;Convert To A:, B: Etc.
  72.                 Mov  [Si],Al                    ;Write It
  73.                 Inc  Si                         ;Forward Ptr
  74.                 Mov  Al,':'                     ;Colour To Follow Drv Spec
  75.                 Mov  [Si],Al                    ;Write It
  76.                 Inc  Si                         ;Forward Ptr
  77.                 Mov  Al,'*'                     ;Global Character
  78.                 Mov  [Si],Al                    ;Write It
  79.                 Inc  Si                         ;Forward Ptr
  80.                 Mov  Al,'.'                     ;Global Character
  81.                 Mov  [Si],Al                    ;Write It
  82.                 Inc  Si                         ;Forward Ptr
  83.                 Mov  Al,'*'                     ;Global Character
  84.                 Mov  [Si],Al                    ;Write It
  85.                 Inc  Si                         ;Forward Ptr
  86.                 Mov  Al,0                       ;Terminate With 0
  87.                 Mov  [Si],Al                    ;Write It
  88.                 Mov  Cx,8                       ;Attribute For Vol Label
  89.                 Les  Di,Dword Ptr[Bp+12]        ;Point To Return String
  90.                 Mov  Ah,4Eh                     ;Function To Seek File
  91.                 Int  21H                        ;Seek Vol Label
  92.                 Jnc  Getv2                      ;Jump If Found
  93.                 Mov  Byte Ptr Es:[Di],0         ;Set Null String Descriptor
  94.                 Jmp  Getv5                      ;Go Quit
  95. Getv2:          Inc  Di                         ;Forward Pointer To First Char
  96.                 Mov  Si,Dx                      ;Si To Start Of Workarea
  97.                 Add  Si,30                      ;Offset To Vol Label
  98.                 Sub  Cl,Cl                      ;Count Strx Len In Cl
  99. Getv3:          Lodsb                           ;Get A Byte
  100.                 Or   Al,Al                      ;Test For Terminating 0
  101.                 Jz   Getv4                      ;Jump When Finished
  102.                 Cmp  Al,'.'                     ;Period?
  103.                 Je   Getv3                      ;Skip It If So
  104.                 Stosb                           ;Transfer Char
  105.                 Inc  Cl                         ;Inc Length Counter
  106.                 Jmp  Short Getv3                ;Go Get Next
  107. Getv4:          Les  Di,Dword Ptr[Bp+12]        ;Return String Address
  108.                 Mov  Es:[Di],Cl                 ;Set Descriptor
  109. Getv5:          Pop  Dx                         ;Restore Prior Dta
  110.                 Pop  Ds                         ;
  111.                 Mov  Ah,1Ah                     ;
  112.                 Int  21H                        ;
  113.                 Pop  Ds                         ;
  114.                 Pop  Bp
  115.                 Ret  6
  116. Getvolume  Endp
  117.  
  118.  
  119. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  120. ;Procedure Readsector(Segment,Offset,Drive,Sector,Number: Word);
  121. ;
  122. ;
  123. Data    Segment
  124.         Extrn  Errreturn:Byte
  125. Data    Ends
  126. ;
  127. ;
  128. Readsector Proc Far
  129.                 Push  Bp                        ;Save Bp
  130.                 Mov   Bp,Sp                     ;Set Up Stack Frame
  131.                 Push  Ds                        ;Save Ds
  132.                 Lds   Bx,Dword Ptr[Bp+12]       ;Get Buffer Address
  133.                 Mov   Al,[Bp+10]                ;Drive Code
  134.                 Dec   Al                        ;Adjust For Turbo
  135.                 Mov   Dx,[Bp+8]                 ;Logical Sector Number
  136.                 Mov   Cx,[Bp+6]                 ;Number Sectors To Read
  137.                 Int   25H                       ;Read The Sector(S)
  138.                 Mov   Bl,0                      ;0 = No Error
  139.                 Jnc   Rsec1                     ;Test For Error
  140.                 Mov   Bl,Ah                     ;Error Code To Bl
  141. Rsec1:          Pop   Cx                        ;Balance Stack
  142.                 Pop   Ds                        ;Restore Ds
  143.                 Pop   Bp                        ;Restore Bp
  144.                 Mov   Errreturn,Bl              ;Set Error Code
  145.                 Ret   10
  146. Readsector Endp
  147.  
  148.  
  149. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  150. ;Procedure Setverify(Setting: Boolean);
  151. ;
  152. ;
  153. Setverify Proc Far
  154.                 Mov  Bx,Sp                      ;
  155.                 Sub  Dl,Dl                      ;Dl Must = 0
  156.                 Mov  Al,Ss:[Bx+4]               ;1 = On, 0 = Off
  157.                 Mov  Ah,2Eh                     ;Dos Func To Set Verify
  158.                 Int  21H                        ;Set Verification
  159.                 Ret  2
  160. Setverify Endp
  161.  
  162.  
  163. ;=-=